const baseUrl = 'http://localhost';
const port = '3000';
const baseConfig = {
  timeout: 5000,
  method: 'GET',
};

const http = function(config) {
  const options = {...baseConfig, ...config, header: {Authorization: 'user' + ' ' + wx.getStorageSync('token'), ...config.header}, url: `${baseUrl}:${port}/${config.url}`};
  return new Promise((resolve, reject) => {
    wx.request({
      ...options,
      success: function(res) {
        resolve(res.data);
      },
      fail: function(err) {
          reject(err);
      }
    })
  });
}


module.exports = {
  http
}